var fs = require('fs');
var logfile = require('./logfile');
var config = require('./config');
var env = config.env;
function delFile(path) {
  fs.unlink(path, (err) => {
    if (err) return console.error(err);
    console.log(path + ' was deleted');
  });
}

setInterval(function() {
  var date = new Date();
  [1,2, 3].forEach(function(val) {
    date.setDate(date.getDate()-1)
    new delFile(logfile(env[3], 'base', date));
    new delFile(logfile(env[3], config.logType[0], date));
    new delFile(logfile(env[1], 'base', date));
    new delFile(logfile(env[1], config.logType[0], date));
  });
}, 1000*60*60*2 /* 两小时 */)